<template>
  <div style="display:inline-block">
    <el-select v-if="type=='select'"
      v-model="model"
      :placeholder="$t('common.pla.pleaseSelect')"
      :multiple="multiple"
      :multiplelimit="multiplelimit"
      :disabled="disabled"
      :size="size"
      style="width: 100%;"
      @change="handleChange"
    >
      <el-option :label="$t('arrangement.arrangeMode0')" value="0" />
      <el-option :label="$t('arrangement.arrangeMode1')" value="1" />
      <el-option :label="$t('arrangement.arrangeMode2')" value="2" />
    </el-select>
    <el-radio-group v-else v-model="model" :disabled="disabled" :size="size" @change="handleChange">
      <el-radio label="0">{{$t('arrangement.arrangeMode0')}}</el-radio>
      <el-radio label="1">{{$t('arrangement.arrangeMode1')}}</el-radio>
      <el-radio label="2">{{$t('arrangement.arrangeMode2')}}</el-radio>
    </el-radio-group>
  </div>
</template>
<script>
/**
 * 单双周下拉框组件
 */
export default {
  name: "WeekTypeSelect",
  model: {
    prop: 'model',
    event: 'change'
  },
  props: {
    model: {
      default: null,
      validator: function (value) {
        // v-model不能为null
        const valide = (value !== null && value !== undefined);
        if(!valide) {
          console.warn('v-model不能为null')
        }
        return valide;
      }
    },// 父组件通过v-model传过来, 如果传来的值为null为出现 Cannot read property 'some' of null
    multiple: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: ''
    },
    multiplelimit: {
      type: Number,
      default: 0
    },
    type:{
      default:"select" // 还可以是radio
    }
  },
  data() {
    return {
    }
  },
  mounted() {
  },
  created() {
  },
  methods: {
    handleChange(val){
      this.$emit('change', val);
    }
  }
};

</script>

<style scoped>
</style>
